<?php
/**
 * 外观模式-门面层
 * 2019年12月11日13:12:24
 */
namespace Application\Common\Facade;

class WeatherFacade
{
    private $cloud;
    private $wind;
    // 构造函数
    public function __construct(array $weathers=array())
    {
        $this -> setWeathers($weathers);
    }
    // 设置天气子类
    public function setWeathers(array $weathers=array())
    {
        foreach($weathers as $k => $v){
            $this -> $k = $v;
        }
    }
    // 获取当前 阴晴、风级
    public function getCurrentLevel()
    {
        if(empty($this -> cloud) || empty($this -> wind)){
            return false;
        }
        $weather = array();
        $weather['cloud'] = $this -> cloud -> getCurrentLevel();
        $weather['wind'] = $this -> wind -> getCurrentLevel();
        return $weather;
    }
    // 只获取当前阴晴
    public function getCurrentCloudLevel()
    {
        if(empty($this -> cloud)){
            return false;
        }
        return $this -> cloud -> getCurrentLevel();
    }
}
